import { StrictMode } from "react";
import "./index.css";
import App from "./App.tsx";
import { createRoot } from "react-dom/client";
import { unstableSetRender } from "antd-mobile";

/**
 * 兼容 react 19
 */
unstableSetRender((node, container) => {
  // @ts-expect-error - React v19兼容性问题
  container._reactRoot ||= createRoot(container);
  // @ts-expect-error - React v19兼容性问题
  const root = container._reactRoot;
  root.render(node);
  return async () => {
    await new Promise((resolve) => setTimeout(resolve, 0));
    root.unmount();
  };
});

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <App />
  </StrictMode>
);
